//
//  IGCommunityListVC.m
//  jingdongfang
//
//  Created by BOE on 2017/8/17.
//  Copyright © 2017年 kevinLY. All rights reserved.
//

#import "IGCommunityListVC.h"
#import "IGCommunityListTableViewCell.h"
#import "IGCommunityModel.h"
#import "IGCommunityDetailVC.h"
#import "IGCommunitySearchVC.h"
#import "SliderViewController.h"

@interface IGCommunityListVC ()<SliderViewControllerDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, assign) IGCommunityListType listType;

@property (nonatomic, strong) SliderViewController *sliderVC;
@property (nonatomic, strong) IGCommunityListCaseVC *myComVC;
@property (nonatomic, strong) IGCommunityListCaseVC *allComVC;

@end

@implementation IGCommunityListVC

- (instancetype)initWithListType:(IGCommunityListType)listType {
    self = [super init];
    if (self) {
        _listType = listType;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = NSLocalizedString(@"Group List", nil);
    self.view.backgroundColor = [UIColor mainBackgroundColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self ig_setupRightButtonItemWithTitle:@"" image:[UIImage imageNamed:@"app_search_icon"] highLightedImage:[UIImage imageNamed:@"app_search_icon"]];

    [self.view addSubview:self.sliderVC];
    [self.sliderVC buildUI];
}

- (SliderViewController *)sliderVC {
    if (!_sliderVC) {
        _sliderVC = [[SliderViewController alloc] initWithFrame:CGRectMake(0, NavigationMagin, KSCREENWIDTH, KSCREENHEIGHT - NavigationMagin)];
        _sliderVC.slideSwitchViewDelegate = self;
        _sliderVC.shadowImageView.backgroundColor = [UIColor clearColor];
        _sliderVC.topScrollView.backgroundColor = [UIColor c3Color];
        _sliderVC.tabItemNormalColor = RGB(115, 115, 115);
        _sliderVC.tabItemSelectedColor =[UIColor blackColor];
    }
    return _sliderVC;
}

- (void)ig_rightButtonPressed:(id)sender {
    [UIViewController ig_pushViewControllerClass:[IGCommunitySearchVC class] animated:YES];
}

#pragma mark - SliderViewControllerDelegate

- (NSUInteger)numberOfTab:(SliderViewController *)view {
    return 2;
}

- (UIViewController *)slideSwitchView:(SliderViewController *)view viewOfTab:(NSUInteger)number {
    if (number == 0) {
        _myComVC = [[IGCommunityListCaseVC alloc] initWithListType:IGCommunityListTypeMeFollow];
//        _myComVC.title = @"我的关注";
        _myComVC.title = NSLocalizedString(@"My Follow", nil);
        return _myComVC;
    } else if (number == 1) {
        _allComVC = [[IGCommunityListCaseVC alloc] initWithListType:IGCommunityListTypeAll];
//        _allComVC.title = @"全部圈子";
        _allComVC.title = NSLocalizedString(@"All Groups", nil);
        return _allComVC;
    }
    return nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
